#include <iostream>
#include <string>

using namespace std;


class Solution
{
public:
    int lengthOfLongestSubstring(string s)
    {
        int idx[128] = {0}, left = 0, len = 0;
        int length = s.length();
        for(int i = 0; i < length; i++)
        {
            left = max(left, idx[(int8_t)s[i]]);
            len = max(len, i - left + 1);
            idx[(int8_t)s[i]] = i + 1;
        }

        return len;
    }
};

//int main()
//{
//    string s;
//    getline(cin, s);
//    int maxSubLength;
//    maxSubLength = Solution().lengthOfLongestSubstring(s);
//    cout << maxSubLength << endl;
//    return 0;
//}
